{% extends "misago/admin/generic/list.html" %}
{% load i18n %}


{% block page-actions %}
<div class="col-auto page-action">
  <a href="{% url 'misago:admin:categories:new' %}" class="btn btn-primary btn-sm">
    <span class="fa fa-plus-circle"></span>
    {% trans "New category" %}
  </a>
</div>
{% endblock %}


{% block table-header %}
<th style="width: 1px;">&nbsp;</th>
<th>{% trans "Category" %}</th>
<th>{% trans "CSS class" %}</th>
<th>{% trans "Threads" %}</th>
<th>{% trans "Posts" %}</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="pr-0">
  <a href="{{ item.get_absolute_url }}" class="btn btn-light btn-sm">
    <span class="fas fa-external-link-alt"></span>
  </a>
</td>
<td>
  {% for i in item.level_range %}
    &nbsp;&nbsp;&nbsp;&nbsp;
  {% endfor %}
  <a href="{% url 'misago:admin:categories:edit' pk=item.pk %}" class="item-name small">
    {{ item }}
  </a>
</td>
<td class="small">
  {% if item.css_class %}
    <pre class="m-0">{{ item.css_class }}</pre>
  {% else %}
    <i class="text-muted">{% trans "Not set" %}</i>
  {% endif %}
</td>
<td class="small">
  {{ item.threads }}
</td>
<td class="small">
  {{ item.posts }}
</td>
<td>
  {% if not item.last %}
    <form action="{% url 'misago:admin:categories:down' pk=item.pk %}" method="post">
      {% csrf_token %}
      <button class="btn btn-light btn-sm" data-tooltip="top" title="{% trans 'Move down' %}">
        <span class="fa fa-chevron-down"></span>
      </button>
    </form>
  {% else %}
    <button class="btn btn-light btn-sm" disabled>
      <span class="fa fa-chevron-down"></span>
    </button>
  {% endif %}
</td>
<td>
  {% if not item.first %}
    <form action="{% url 'misago:admin:categories:up' pk=item.pk %}" method="post">
      {% csrf_token %}
      <button class="btn btn-light btn-sm" data-tooltip="top" title="{% trans 'Move up' %}">
        <span class="fa fa-chevron-up"></span>
      </button>
    </form>
  {% else %}
    <button class="btn btn-light btn-sm" disabled>
      <span class="fa fa-chevron-up"></span>
    </button>
  {% endif %}
</td>
<td>
  <div class="dropdown">
    <button class="btn btn-light btn-sm dropdown-toggle" type="button" id="item-optioms-{{ item.pk }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      <i class="fas fa-ellipsis-h"></i>
    </button>
    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="item-optioms-{{ item.pk }}">
      {% for action in extra_actions %}
        <a href="{% url action.link pk=item.pk %}" class="dropdown-item">
          {{ action.name }}
        </a>
      {% endfor %}
      <a class="dropdown-item" href="{% url 'misago:admin:categories:edit' pk=item.pk %}">
        {% trans "Edit category" %}
      </a>
      <a class="dropdown-item" href="{% url 'misago:admin:categories:delete' pk=item.pk %}">
        {% trans "Delete category" %}
      </a>
    </div>
  </div>
</td>
{% endblock %}


{% block blankslate %}
<td colspan="8">
  {% trans "No categories are set." %}
</td>
{% endblock blankslate %}
